<?php

error_reporting(E_ALL&~E_NOTICE&~E_WARNING);

define('MCC_ROOT',dirname(__FILE__));
define('WEB_ROOT',dirname(dirname(__FILE__)));
define('IN_MCC',TRUE);

require_once MCC_ROOT.'/include/global.inc.php';


$timezoneoffset = 8;
$timezoneoffset=$timezoneoffset>0 ? '-'.$timezoneoffset : '+'.$timezoneoffset;
function_exists('date_default_timezone_set') && date_default_timezone_set("Etc/GMT$timezoneoffset");

$defined_vars = get_defined_vars();

foreach ($defined_vars as $_key => $_value)

{

	if(!in_array($_key,array('_POST','_GET','GLOBALS','_FILES','_SERVER','_COOKIE','_SESSION')))

	{

		${$_key} = '';

		unset(${$_key});

	}

}

$t_array = explode(' ',microtime());

$systime = $t_array[0]+$t_array[1];

$timestamp = time();

get_magic_quotes_gpc()? define('MAGIC_QUOTES_GPC',TRUE) : define('MAGIC_QUOTES_GPC',FALSE);

if(!MAGIC_QUOTES_GPC)

{

	addslashes_deep($_POST);

	addslashes_deep($_GET);

	addslashes_deep($_COOKIE);

}

addslashes_deep($_FILES);

if($_SERVER['HTTP_X_FORWARDED_FOR'])

{

	$onlineip = $_SERVER['HTTP_X_FORWARDED_FOR'];

	$c_agentip = 1;

}elseif ($_SERVER['HTTP_CLIENT_IP'])

{

	$onlineip = $_SERVER['HTTP_CLIENT_IP'];

	$c_agentip = 1;

}elseif ($_SERVER['REMOTE_ADDR'])

{

	$onlineip = $_SERVER['HTTP_CLIENT_IP'];

	$c_agentip = 0;

}

require_once WEB_ROOT.'/config.inc.php';

import_request_variables('pgc');

if($uptype=='bakupds')

{

	$charset = '';

	$dbcharset = '';

}

require_once MCC_ROOT.'/include/db_mysql.class.php';

$db = new dbstuff;
$db->connect($dbhost, $dbuser, $dbpw, $dbname, $pconnect);


$_DCOOKIE = $_DSESSION =  array();

$prelength = strlen($cookiepre);

foreach($_COOKIE as $key => $val) {

	if(substr($key, 0, $prelength) == $cookiepre) {

		$_DCOOKIE[(substr($key, $prelength))] = MAGIC_QUOTES_GPC ? $val : addslashes_deep($val);

	}

}//把COOKIE里面的值过滤后倒入

$MSYS_AUTH_KEY = md5($authkey.$_SERVER['HTTP_USER_AGENT']);

list($msys_pw, $msys_uid,$msys_time) = empty($_DCOOKIE['auth']) ? array('', '', 0) : addslashes_deep(explode("\t", authcode($_DCOOKIE['auth'], 'DECODE')));

if(is_numeric($msys_uid)&&strlen($msys_pw)>6)

{

	$sql = "SELECT * FROM bl_members WHERE uid='$msys_uid' AND password='$msys_pw'";

	$query = $db->query($sql);

	$qend = $db->fetch_array($query);

	if($qend)

	{

		$msys_user = $qend['username'];

		$userdb = array();

		$userdb['username'] = $qend['username'];

		$userdb['email'] = $qend['email'];

		$userdb['tentqq'] = $qend['tentqq'];

		$userdb['logindate'] = gmdate("Y-m-d H:i:s",$qend['logindate']);

		$userdb['level'] = $qend['level'];

		$userdb['allowoperation'] = explode(':',($qend['allowoperation']));

		$larr = explode(':',($qend['allowoperation']));

	}

	else 

	{

		$msys_pw = $msys_uid = $larr='';

	}

}

else 

{

	$msys_pw = $msys_uid = $larr='';

}

$PHP_SELF = $_SERVER['PHP_SELF'] ? $_SERVER['PHP_SELF'] : $_SERVER['SCRIPT_NAME'];
$BASESCRIPT = basename($PHP_SELF);
list($BASEFILENAME) = explode('.', $BASESCRIPT);
$boardurl = htmlspecialchars('http://'.$_SERVER['HTTP_HOST'].preg_replace("/\/+(api|archiver|wap)?\/*$/i", '', substr($PHP_SELF, 0, strrpos($PHP_SELF, '/'))).'/');

if(!$msys_uid&&!strstr($PHP_SELF,'login.php')&&!strstr($PHP_SELF,'msysck.php')&&!strstr($PHP_SELF,'sendpwd.php'))
{	
adminmsg('没有登陆，没有权限进行操作！','login.php?action=login',1);
}


//验证不为空
function checkValues($names){//
	foreach($names as $key=>$name){
		//echo "<br>\n=".$key."=".$name;
		$n=trim($name);
		if(empty($n)){
			//die('aaa');
			//echo "<br>\nkey=".$key."&nbsp;name=".$name."&nbsp;f=".$n;
			return false;
		}	
	}
	return true;    
} // end func

?>